﻿/*****************************************************************************
	SNEGA STG GAME ENGINE 0.7a
	Copyright (C) 2009, Xiaohan Tian (snega0223)
	
	http://code.google.com/p/sng-actionscript-stg-engine/
	
	This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License(LGPL) as
	published by the Free Software Foundation, either version 3 of the 
	License, or(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.
	
	You should have received a copy of the GNU Lesser General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/

package com.sng.stg.game.event 
{
	import com.sng.stg.game.Player.Player;
	import com.sng.stg.game.StageViewer;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author snega
	 */
	public class PlayerHit extends ContinuousEvent
	{
		public var _player:Player = null;
		public var _frame:int = 0;
		
		public function PlayerHit(stage:StageViewer) 
		{
			this._stage = stage;
			this._player = stage._player;
			this._player.alpha = 0;
			this._player._notInvincible = false;
			
			this._stage._playerEnable = false;
			
			this._player.x = 195;
			this._player.y = 531;
			
			this._stage._continuousEventList.push(this);
		}
		
		override public function process():void {
			if (!this._stage._playerEnable) {
				if (--this._player.y == 491) {
					this._stage._playerEnable = true;
				}
			}
			
			if (++this._frame == 120) {
				this._player._notInvincible = true;
				this._player.alpha = 1;
				this.remove();
				return;
			}
			
			if (this._player.alpha == 0) {
				this._player.alpha = 0.5;
			}
			else {
				this._player.alpha = 0;
			}
		}
		
	}
	
}